-
Notifications
You must be signed in to change notification settings - Fork 41
Conversation
This will be dynamic
To replace the removed constant, getAuctionBasePercentage calculates the current base auction percentage such that given sorrect collateralization the base will be 100% of the backing value eg: collateralization: 500 collateral percent-> 20% base auction duration 150 collateral percent -> 66% base auction duration 100 collateral percent -> 100% base auction duration Note: This breaks when we go under 100% collateralization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few notes, main one is: we now have to store that initial collateralization percentage :/
/// in a 100% bond value base auction given perfect collateralization. | ||
function getAuctionBasePercentage(Deposit storage _d) internal view returns (uint256) { | ||
ITBTCSystem _sys = ITBTCSystem(_d.TBTCSystem); | ||
uint256 initialCollateralizedPercent = _sys.getInitialCollateralizedPercent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to store this at deposit creation, otherwise the existing deposit's behavior changes based on governance actions :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
derp.
|
||
const initialCollateralization = await tbtcSystemStub.getInitialCollateralizedPercent() | ||
|
||
// 10000 to avoid losing value to truncating is solidity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in?
const initialCollateralization = await tbtcSystemStub.getInitialCollateralizedPercent() | ||
|
||
// 10000 to avoid losing value to truncating is solidity. | ||
const expecged = new BN(10000).div(initialCollateralization) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sp
Using current system initialCollateralizedPercent does not correctly reflect the individual Deposit's initialCollateralizedPercent. Track initialCollateralizedPercent for each individual Deposit
@Shadowfiend, ready here |
@@ -33,6 +33,7 @@ library DepositUtils { | |||
uint256 lotSizeSatoshis; | |||
uint8 currentState; | |||
uint256 signerFeeDivisor; | |||
uint128 initialCollateralizedPercent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the two below seem like they can be smaller than uint128
, perhaps? Could even be a uint8
? Maybe a uint16
if we want to allow ourselves maximum flexibility, but our percentages are expressed as percentages, so uint8
gives us up to 250% as a representation 🤔
Not sure if the Solidity compiler is good enough to pack things together and save us gas in that case though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uint16
for some peace of mind. Also, the enforced initialCollateralizedPercent
max is 300, which is over the 255 uint8 limit.
Solidity will automatically pack where possible, given the variables fit into a single 32-byte increment. two uint128
s should be packed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this looks good; let's handle variable sizing in a separate PR and merge this in the meantime.
Putting a hold here as @mhluongo wants to leave <100% collateralization as an available initial percentage, so we need to see how that affects decisions here. |
For now, moving forward with 100% initial collateralization as the minimum (adding enforcement in a separate PR). |
Enforcement is in #541. |
Replace
AUCTION_BASE_PERCENTAGE
constant with a function that returns base percentage given theinitialCollateralizationPercent
fromtbtcSystem
The base collateralization percentage should be the percentage of the
InitialCollateralizationPercent
that will result in a 100% bond value base auction assuming perfect collateralization.But why
Starting auctions assuming proper collateralization reduces the attractiveness attacks where a liquidator can get ETH for a discount by manipulating oracles to initiate liquidation on a well-collateralized deposit.